import { defineStore } from "pinia";
import { reqC1,reqC2,reqC3 } from "@/api/product/attr/index";
import type {CategoryResponseData} from '@/api/product/attr/type'
import type {CategoryState} from './type/type'
const useCategoryStore = defineStore("Category", {
  state: ():CategoryState => {
    return {
        c1Arr:[],
        c1Id:'',
        c2Arr:[],
        c2Id:'',
        c3Arr:[],
        c3Id:''
    };
  },
  actions: {
    async getC1() {
      let result:CategoryResponseData = await reqC1();
      this.c1Arr = result.data
    },
    async getC2(){
      let result:CategoryResponseData = await reqC2(this.c1Id)
      this.c2Arr = result.data
    },
    async getC3(){
        let result:CategoryResponseData = await reqC3(this.c2Id)
        this.c3Arr = result.data
      }
  },
});
export default useCategoryStore;
